package zuoye.zy5;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class foght_landowner {
    public static void main(String[] args) {
        List<Card> allcards = new ArrayList<>();
        //定义花色和点数的数组
        String[] colors = {"♥", "♠", "♣", "♦"};
        String[] points = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        int size = 0;
        for (String point : points) {
            size++;
            for (String color : colors) {

                Card card = new Card(color, point, size);
                allcards.add(card);
            }
        }
        allcards.add(new Card("🃏", "", 888));
        allcards.add(new Card("🤡", "", 666));
        System.out.println(allcards);
        Collections.shuffle(allcards);
        System.out.println(allcards);
        List<Card> player1 = new ArrayList<>();
        List<Card> player2 = new ArrayList<>();
        List<Card> player3 = new ArrayList<>();
        List<Card> dipai = new ArrayList<>();
        for (int i = 0; i < allcards.size() - 3; i++) {
            if (i % 3 == 0) {
                player1.add(allcards.get(i));
            } else if (i % 3 == 1) {
                player2.add(allcards.get(i));
            } else {
                player3.add(allcards.get(i));
            }
            dipai = allcards.subList(allcards.size() - 3, allcards.size());

        }
        System.out.println("玩家1的牌" + player1);
        System.out.println("玩家2的牌" + player2);
        System.out.println("玩家3的牌" + player3);
        System.out.println("底牌" + dipai);

        Collections.sort(player1,(c1, c2)->c1.getSize()-c2.getSize());
        Collections.sort(player2,(c1, c2)->c1.getSize()-c2.getSize());
        Collections.sort(player3,(c1, c2)->c1.getSize()-c2.getSize());
        System.out.println("玩家1的牌" + player1);
        System.out.println("玩家2的牌" + player2);
        System.out.println("玩家3的牌" + player3);
        System.out.println("底牌" + dipai);

    }
}
